package com.mt.roll.wms.controller;

import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.validator.groups.PageGroup;
import com.mt.roll.core.validator.groups.UpdateGroup;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.wms.params.StorageBoxInfoParam;
import com.mt.roll.wms.params.StorageBoxInfoQueryParam;
import com.mt.roll.wms.service.StorageBoxInfoService;
import com.mt.roll.wms.vo.StorageBoxInfoVo;
import com.mt.roll.wms.vo.StorageBoxVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;

/**
 * @auther yanyang
 * @date 2021/11/03 15:17
 */

@RestController
@RequestMapping(CommonConstant.API_MODULE_WMS + "storagebox")
@Slf4j
@Api(value = "基础存储箱信息", tags = "基础存储箱信息", hidden = false)

public class StorageBoxInfoController extends BaseController {

    @Autowired
    private StorageBoxInfoService storageBoxInfoService;

    @PostMapping(value = "page")
    @ApiOperation(value = "获取分页存储箱信息")
    private R<PageVo<StorageBoxInfoVo>> page(@Validated({PageGroup.class, Default.class}) @RequestBody StorageBoxInfoQueryParam storageBoxInfoQueryParam){
        return storageBoxInfoService.page(storageBoxInfoQueryParam);
    }

    @PostMapping(value = "getById")
    @ApiOperation(value = "获取存储箱信息")
    private R<StorageBoxInfoVo> getById(@Validated @RequestBody IdParam idParam) {
        return storageBoxInfoService.get(idParam);
    }

    @PostMapping(value = "add")
    @ApiOperation(value = "新增")
    private R<IdVo> add(@Validated({AddGroup.class, Default.class}) @RequestBody StorageBoxInfoParam storageBoxInfoParam) {
        return storageBoxInfoService.add(storageBoxInfoParam);
    }

    @PostMapping(value = "update")
    @ApiOperation(value = "更新")
    private R<IdVo> update(@Validated({UpdateGroup.class, Default.class}) @RequestBody StorageBoxInfoParam storageBoxInfoParam) {
        return storageBoxInfoService.update(storageBoxInfoParam);
    }

    @PostMapping(value = "delete")
    @ApiOperation(value = "删除")
    private R<IdVo> delete(@Validated @RequestBody IdParam idParam) {
        return storageBoxInfoService.delete(idParam);
    }

    @PostMapping(value = "getCode")
    @ApiOperation(value = "获取code")
    private R<String> getCode() {
        return storageBoxInfoService.getCode();
    }
}
